﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;

public partial class MembershipCard_hd_Default2 : WeiPage
{
    promotionBO mbo = new promotionBO();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["code"] != null)
            {
                try
                {
                    string url = string.Format(@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + GetAppid() + "&secret=" + GetSecret() + "&code={0}&grant_type=authorization_code", Request.QueryString["code"].ToString());
                    string token = PostRequest(url);
                    if (token.Contains("7200"))
                    {
                        string[] b = token.Split('\"');
                        Session["FromUserName"] = b[13];
                        Session["ToUserName"] = GetAppid();
                    }
                }
                catch (Exception)
                {

                }
            }
            if (Request.QueryString["ID"] != null)
            {
                promotion m = mbo.GetModel(int.Parse(Request.QueryString["id"].ToString()));
                if (m != null)
                {
                    title.Text = m.Name;
                    nr.InnerHtml = m.Content;
                }
            }
        }
    }
}